package com.wicket.okrframework.biz.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.wicket.okrframework.base.service.MDeptPositionRelationshipService;
import com.wicket.okrframework.base.service.MPostService;
import com.wicket.okrframework.base.service.MPrivacyDistributionService;
import com.wicket.okrframework.base.service.MSceneRoleService;
import com.wicket.okrframework.base.service.dto.req.BatchQueryTributPowerListReq;
import com.wicket.okrframework.base.service.dto.req.QueryPostDetailReq;
import com.wicket.okrframework.biz.service.dto.req.*;
import com.wicket.okrframework.biz.service.dto.res.*;
import com.wicket.okrframework.common.util.RedisUtil;
import com.wicket.okrframework.dal.po.mbg.DeptPositionRelationship;
import com.wicket.okrframework.dal.po.mbg.Post;
import com.wicket.okrframework.dal.po.mbg.PrivacyDistribution;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import com.wicket.okrframework.base.service.MUserinfoService;
import com.wicket.okrframework.dal.po.mbg.Userinfo;
import com.wicket.okrframework.base.service.dto.req.BatchQueryUserinfoListReq;

/**
 * @author ：
 * @date ：
 *
 *
 * @version 1.0
 */
@Service
public class NullServiceImpl
        implements com.wicket.okrframework.biz.service.NullService {

    @Resource
    private RedisUtil redisUtil;
    @Resource
    private MPrivacyDistributionService mPrivacyDistributionService;
    @Resource
    private MDeptPositionRelationshipService mDeptPositionRelationshipService;
    @Resource
    private MSceneRoleService mSceneRoleService;
    @Resource
    private MPostService mPostService;
@Resource
  private MUserinfoService mUserinfoService;
//@Resource
    //private undefinedService undefinedService;

    /**
     * D1-2批量查询权限分配列表[703]
     */
    @Trace(operationName = "D1-2批量查询权限分配列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public BatchQueryTributPowerListRespDto batchQueryTributPowerList(BatchQueryTributPowerListReqDto reqDto) {


        //步骤0: 1-2-12批量查询权限分配列表 - batchQueryTributPowerList
        List<PrivacyDistribution> listPrivacyDistribution = null;
        BatchQueryTributPowerListReq batchQueryTributPowerListReq = new BatchQueryTributPowerListReq();
        if (reqDto != null) {
            batchQueryTributPowerListReq.setTypeCode(reqDto.getTypeCode());//sourceId:14230_1
            batchQueryTributPowerListReq.setTributPowerList(reqDto.getTributPowerList());//sourceId:14228_1
            batchQueryTributPowerListReq.setPrivacyCode(reqDto.getPrivacyCode());//sourceId:64280_1
            batchQueryTributPowerListReq.setIsDataPrivacy(reqDto.getIsDataPrivacy());//sourceId:64281_1
            batchQueryTributPowerListReq.setDataModel(reqDto.getDataModel());//sourceId:64324_1
            batchQueryTributPowerListReq.setPrivacyCategory(reqDto.getPrivacyCategory());//sourceId:64282_1
            batchQueryTributPowerListReq.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:64283_1
        }

        /*1-2-12批量查询权限分配列表[702]   */
        listPrivacyDistribution = mPrivacyDistributionService.batchQueryTributPowerList(batchQueryTributPowerListReq);


        BatchQueryTributPowerListRespDto retData = new BatchQueryTributPowerListRespDto();
        retData.setTributPowerList(listPrivacyDistribution.stream().map(item -> BeanUtil.toBean(item, TributPowerDto.class)).collect(Collectors.toList()));//sourceId:14233_1


        return retData;
    }

    /**
   * D1-3批量新增部门岗位职务关系[1496]
   * gen by moon at 10/2/2022, 12:09:01 AM
   */
  @Trace(operationName = "D1-3批量新增部门岗位职务关系")
  @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Transactional(rollbackFor=Exception.class)
  @Override
  public BatchAddDeptPositionRespDto batchAddDeptPosition(BatchAddDeptPositionReqDto reqDto){
    
      
      //步骤0: 1-3-11批量新增部门岗位职务关系 - batchAddDeptPosition
     boolean bOOLEAN ;
    List<DeptPositionRelationship> listDeptPositionRelationship=new ArrayList<>();
  if(reqDto!=null){
      listDeptPositionRelationship = //objList-to-objLists
        reqDto.getOrgDeptPositionList().stream().map(item -> {
      DeptPositionRelationship elm = new DeptPositionRelationship();
      if(item!=null){
      elm.setPositionId(item.getPositionId());//SimpleFieldAssign//sourceId:18400_2
elm.setOrgTypeCode(item.getPositionId());//SimpleFieldAssign//sourceId:18401_2
elm.setOrgEntityId(item.getOrgEntityId());//SimpleFieldAssign//sourceId:18402_2
elm.setOrganizationId(item.getOrganizationId());//SimpleFieldAssign//sourceId:18403_2
elm.setOrderNumber(item.getOrderNumber());//SimpleFieldAssign//sourceId:18404_2
    }
        return elm;
      }).collect(Collectors.toList());//objList-to-objLists//sourceId:40061_1
    }
  
    /*1-3-11批量新增部门岗位职务关系[1497]   */
    
      bOOLEAN = mDeptPositionRelationshipService.batchAddDeptPosition(listDeptPositionRelationship);
      
      
      
    
BatchAddDeptPositionRespDto retData = new BatchAddDeptPositionRespDto();
  
  

  
  
return retData;
  }

    /**
     * D1-1查询内容对象与标签关系详情[834]
     */
    @Trace(operationName = "D1-1查询内容对象与标签关系详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public QueryTagRelDetailRespDto queryTagRelDetail(QueryTagRelDetailReqDto reqDto) {


// TODO: 2022/6/19 晓东:设计插件正确，但是生成错误
        //步骤0: 1-1-17查询内容对象与标签关系详情 - queryTagRelDetail
//        Object unknown = null;
//        Object queryTagRelDetailReq = new Object();
//
//
//        /*1-1-17查询内容对象与标签关系详情[829]   */
//        unknown = undefinedService.queryTagRelDetail(queryTagRelDetailReq);


        QueryTagRelDetailRespDto retData = new QueryTagRelDetailRespDto();


        return retData;
    }

    /**
     * D1-1查询内容对象与标签关系列表[833]
     */
    @Trace(operationName = "D1-1查询内容对象与标签关系列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public QueryTagRelListRespDto queryTagRelList(QueryTagRelListReqDto reqDto) {


        QueryTagRelListRespDto retData = new QueryTagRelListRespDto();


        return retData;
    }

    /**
     * D1-2删除自定义角色[641]
     */
    @Trace(operationName = "D1-2删除自定义角色")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public DeleteRoleRespDto deleteRole(DeleteRoleReqDto reqDto) {


        //步骤0: 1-2-08删除角色 - deleteRole
        boolean bOOLEAN;
        String string = new String();
        if (reqDto != null) {
            string = reqDto.getRoleId();
            ;//sourceId:10264_1
        }

        /*1-2-08删除角色[75]   */
        bOOLEAN = mSceneRoleService.deleteRole(string);


        DeleteRoleRespDto retData = new DeleteRoleRespDto();


        return retData;
    }

    /**
   * D1-3查询职位详情	[981]
   * gen by moon at 10/2/2022, 7:52:56 AM
   */
  @Trace(operationName = "D1-3查询职位详情	")
  @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Transactional(rollbackFor=Exception.class)
  @Override
  public QueryPostDetailRespDto queryPostDetail(QueryPostDetailReqDto reqDto){
    
      
      Post post_1 =null;
//步骤0: 1-3-08查询职位详情 - queryPostDetail
     Post post = null;
    QueryPostDetailReq queryPostDetailReq=new QueryPostDetailReq();
  if(reqDto!=null){
      queryPostDetailReq.setPostId(reqDto.getPostId());//SimpleFieldAssign//sourceId:21012_1
    }
  
    /*1-3-08查询职位详情[213]   */
    
      post = mPostService.queryPostDetail(queryPostDetailReq);
      
      
      post_1 = post;
    
QueryPostDetailRespDto retData = new QueryPostDetailRespDto();
  if(post_1!=null){
      retData.setPostId(post_1.getPostId());//SimpleFieldAssign//sourceId:47587_1
retData.setPostNumber(post_1.getPostNumber());//SimpleFieldAssign//sourceId:47588_1
retData.setPostName(post_1.getPostName());//SimpleFieldAssign//sourceId:47589_1
retData.setSubjectLifeCycle(post_1.getSubjectLifeCycle());//SimpleFieldAssign//sourceId:47590_1
retData.setOperationInductionId(post_1.getOperationInductionId());//SimpleFieldAssign//sourceId:47591_1
retData.setOperateTime(post_1.getOperateTime());//SimpleFieldAssign//sourceId:47592_1
    }
  

  
  
return retData;
  }
/**
   * D1-2批量查询个人资料列表[1020]
   * gen by moon at 11/1/2022, 7:47:37 AM
   */
  @Trace(operationName = "D1-2批量查询个人资料列表")
  @Tags({@Tag(key = "参数",value = "arg[0]"),
            @Tag(key = "返回值",value = "returnedObj")})
  @Transactional(rollbackFor=Exception.class)
  @Override
  public BatchQueryUserinfoRespDto batchQueryUserinfo(BatchQueryUserinfoReqDto reqDto){
    
      
      List<Userinfo> listUserinfo_1 =new ArrayList<>();
//步骤0: 1-2-02批量查询个人资料列表 - batchQueryUserinfoList
     List<Userinfo> listUserinfo =new ArrayList<>();
    BatchQueryUserinfoListReq batchQueryUserinfoListReq=new BatchQueryUserinfoListReq();
  if(reqDto!=null){
      batchQueryUserinfoListReq.setUserList(reqDto.getUserinfoList());//list-field-assign//sourceId:21246_1
    }
  
    /*1-2-02批量查询个人资料列表[52]   */
    
      listUserinfo = mUserinfoService.batchQueryUserinfoList(batchQueryUserinfoListReq);
      
      
      listUserinfo_1 = listUserinfo;
    
BatchQueryUserinfoRespDto retData = new BatchQueryUserinfoRespDto();
  retData.setUserInfoList(listUserinfo_1.stream().map(item -> BeanUtil.toBean(item, UserInfoDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:21249_1
  

  
  
return retData;
  }
    //
}
